//
// RS Game Framework
// Copyright © 2010 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#ifndef RS_GRAPHICS_TEXTURE2D_HPP
#define RS_GRAPHICS_TEXTURE2D_HPP

#include "rs/graphics/GraphicsForwards.hpp"
#include "rs/graphics/Resource.hpp"	
#include "rs/graphics/Texture2DDescription.hpp"

namespace rs
{
    namespace graphics
    {        
        class Texture2D : public Resource
        {
            RS_DECLARE_POLYMORPHIC_REFLECTION();
            
        public:
            
            RsSize GetWidth() const;
            
            RsSize GetHeight() const;
            
            RsSize GetMipMapCount() const;
            
            TextureFormat const& GetFormat() const;
            
            virtual void GenerateMipmaps() = 0;
            
            virtual void SetData(void const* data, UInt8 mipLevel = 0) = 0;
            
            virtual void SetData(void const* data, RsSize x, RsSize y, RsSize width, RsSize height, UInt8 mipLevel = 0) = 0;
            
            virtual void const* GetData(UInt8 mipLevel = 0) const = 0;
            
        protected:
            
            Texture2D(Texture2DDescription const& description);
            
        protected:
            
            RsSize width_;
            RsSize height_;
            TextureFormat format_;
            UInt8 numMipmaps_;
        };
        
                
        inline Texture2D::Texture2D(Texture2DDescription const& description)
        : Resource(description),
          width_(description.GetWidth()),
          height_(description.GetHeight()),
          format_(description.GetFormat()),
          numMipmaps_(description.GetMipMapCount()) {
        }
        
        
        inline RsSize Texture2D::GetWidth() const {
            return width_;
        }
        
        inline RsSize Texture2D::GetHeight() const {
            return height_;
        }
        
        inline RsSize Texture2D::GetMipMapCount() const {
            return numMipmaps_;
        }
        
        inline TextureFormat const& Texture2D::GetFormat() const {
            return format_;
        }
    }
}

#endif // RS_GRAPHICS_TEXTURE2D_HPP